Show page count with prefix
authorjustbur <justin@burkett.cc>
Tue, 21 Jul 2015 12:09:41 +0000 (08:09 -0400)
committerjustbur <justin@burkett.cc>
Tue, 21 Jul 2015 12:09:41 +0000 (08:09 -0400)
which-key.el

index 05552b3315efef6739b90772ab63825ebbf7a43c..5d3ac667ea7cfd880f99047b430c1b545224d4e1 100644 (file)
@@ -845,6 +845,7 @@ element in each list element of KEYS."
         (page-width 0) (n-pages 0)
         page-cols pages keys/page page-widths)
     (if (> (car (car cols-w-widths)) avl-width)
+        ;; give up if first column doesn't fit
         (list :pages nil :page-height 0 :page-widths '(0)
               :keys/page '(0) :n-pages 0 :tot-keys 0)
         (dolist (col cols-w-widths)
@@ -919,15 +920,22 @@ PREFIX-KEYS holds the description of the prefix keys."
              (n-shown (nth i (plist-get which-key--pages-plist :keys/page)))
              (n-tot (plist-get which-key--pages-plist :tot-keys))
              (prefix-w-face (which-key--propertize-key prefix-keys))
-             (prefix-width (string-width prefix-w-face))
-             spaces)
+             (status-left (propertize (format "%s/%s" (1+ i) n-pages)
+                                      'face 'font-lock-comment-face))
+             (status-top (propertize (format "[%s/%s]" (1+ i) n-pages)
+                                     'face 'font-lock-comment-face))
+             (first-col-width (+ 2 (max (string-width prefix-w-face)
+                                        (string-width status-left))))
+             (prefix-left (s-pad-right first-col-width " " prefix-w-face))
+             (status-left (s-pad-right first-col-width " " status-left))
+             new-end lines)
         (cond ((eq which-key-show-prefix 'left)
-               (setq spaces (s-repeat prefix-width " ")
-                     page (concat
-                           prefix-w-face "  "
-                           (s-replace "\n" (concat "\n  " spaces) page))))
+               (setq lines (split-string page "\n")
+                     first (concat prefix-left (car lines) "\n" status-left)
+                     new-end (concat "\n" (s-repeat first-col-width " "))
+                     page  (concat first (mapconcat #'identity (cdr lines) new-end))))
               ((eq which-key-show-prefix 'top)
-               (setq page (concat prefix-w-face "-\n" page))))
+               (setq page (concat prefix-w-face "-  " status-top "\n" page))))
         (which-key--lighter-status n-shown n-tot)
         (if (eq which-key-popup-type 'minibuffer)
             (let (message-log-max) (message "%s" page))